<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.EquipmentDao"%>
<%@page import="com.shsh.safemanage.model.Equipment"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.util.Constants"%>

<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：中国石化安全问题管理平台 &gt;&gt; 通用问题填报
</div>
<%
User user = (User) session.getAttribute(Constants.SESSION_USER);

session.removeAttribute(Constants.SESSION_MANAGE_GROUP_USER);
session.removeAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);
session.removeAttribute(Constants.SESSION_PROBLEM_EQUIPMENT);
%>
<div class="tt">问题填报卡</div>
<div class="content">
	<table align="center" border="1" width="700" cellpadding="0"
		cellspacing="0">
		<tr>
			<td class="td1" height="35" id="chooseDepartEquipTD">
				<%@include file="write_problem_depart_equip_section.jsp" %>
			</td>
		</tr>
		<tr>
			<td class="td1" height="35">
				<span style="margin-left: 40px" class="span1">发现问题标题：</span>
				<input type="text" id="problemTitle" size="45" />
			</td>
		</tr>
		<tr>
			<td class="td1" height="35">
				<span style="margin-left: 40px" class="span1">发现问题内容：</span>
				<br />
				<textarea style="width: 600px; height: 100px; margin-left: 60px" id="problemContent"></textarea>
			</td>
		</tr>
		<tr>
			<td class="td1" height="35">
				<span style="margin-left: 40px" class="span1">整改措施：</span>
				<br />
				<textarea style="width: 600px; height: 100px; margin-left: 60px" id="zhenggai_cuoshi"></textarea>
			</td>
		</tr>
		<tr>
			<td class="td1" height="35">
				<div id="informPersonDiv">
				<%@include file="write_problem_informed_person.jsp" %>
				</div>
				<div id="chooseManageGroupUserDiv">
				<%@include file="choose_manage_group_user.jsp"%>
				</div>
			</td>
		</tr>
		<tr>
			<td class="td1" height="35">
				<span style="margin-left: 40px" class="span1">填报人及时间：</span>
				<span><%=user.getDepartment1Name()%>-<%=user.getDepartment2Name()%>-<%=user.getDepartment3Name()%></span>
				<span><%=user.getName()%></span>
				<span><%=Util.formatDateTime(Calendar.getInstance())%></span>
			</td>
		</tr>
		<tr>
			<td class="td1" height="35">
				<input type="button" style="margin-left: 300px" value="提 交" onclick="writeProblem()" />
				<input type="button" style="margin-left: 30px" value="取 消" onclick="cancelProblem()" />
			</td>
		</tr>
	</table>
</div>

<script type="text/javascript">
function writeProblem() {
	if (getElementValueByID('problemTitle') == '') {
		$.dialog.alert('请输入标题');
		return;
	}
	if (getElementValueByID('problemContent') == '') {
		$.dialog.alert('请输入问题内容');
		return;
	}
	if (getElementValueByID('zhenggai_cuoshi') == '') {
		$.dialog.alert('请输入整改措施');
		return;
	}
	if ($.dialog.confirm('您确定提交此问题吗？', function(){
		openWaitingDialog('waitingDialog');
		$.ajax({
			type:'post',
			url:'write_problem_process.jsp',
			data:{
				problemTitle: getElementValueByID('problemTitle'),
				problemContent: getElementValueByID('problemContent'),
				zhenggai_cuoshi: getElementValueByID('zhenggai_cuoshi')
			},
			success:function(data,state,xmlhttp){
				var obj = null;
				try {
					obj = eval('(' + data + ')');
				} catch (e) {
				}
				if (typeof(obj.isSuccess) != 'undefined') {
					closeWaitingDialog('waitingDialog');
					if (obj.isSuccess == 'true') {
						$.dialog('问题填报成功！', function() { loadPageSection('/safe_manage/user_infor.jsp', 'mainContentDiv'); });
					} else {
						$.dialog.alert(obj.error);
					}
				}
			}
		});
	}, function(){}));
}

function cancelProblem() {
	if ($.dialog.confirm('您确定取消此问题吗？', function(){
		loadPageSection('/safe_manage/user_infor.jsp', 'mainContentDiv');
	}, function(){}));
}
</script>